package com.zprmb.udzt;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
import com.zprmb.udzt.http.AjaxParams;
import com.zprmb.udzt.ll.BaseHelper;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.LogUtils;
import com.zprmb.udzt.util.MyReceiver;
import com.zprmb.udzt.util.Regular;
import com.zprmb.udzt.util.ToJSON;
import com.zprmb.udzt.util.ToastUtil;
import com.zprmb.udzt.util.VolleryUtil;
import com.zprmb.udzt.util.VoteCalculator;
import com.zprmb.udzt.view.MutiProgress;
import com.zprmb.udzt.view.WaveHelper;
import com.zprmb.udzt.view.WaveView;

import org.json.JSONObject;

import java.text.DecimalFormat;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 项目详情
 * @author shenshao
 *
 */
public class DetailsActivity extends BaseActivity implements OnClickListener,
		OnRefreshListener2<ScrollView> {
	private ProgressBar sk;
	private Button btn, feature1, feature2, feature3;
	private TextView product_name, product_remain, product_rate, invest_num,
			tv_progress, product_money, progress_text, tv_countinvest,tv_countinvest2;
	private WaveView waveView;
	private TextView my_remain, tv_v4_pay_shouyi, tv_v4_pay_redpackage,
			tv_use_red, tv_youhui_type, tv_youhui_date, tv_yuan;
	private EditText et_money;
	private Double add_rate=(double) 0,curAmount=0.0,maxcurAmount;
	private TextView user_yue,tv_tishi;
	private LinearLayout li_progress;
	private View space_view,space_view2;
	private View de_bbt_invest,de_uplan_invest;
	private RelativeLayout rl_detail,rl_comment,rl_detail2;
	private PullToRefreshScrollView sv;
	private WaveHelper helper;
	
	private int up=0,result=0,arg3=0,useFundAmountInvestFlag=1;
	private TextView jiahao, detail_add;
	private TextView  tv_progress_data1, tv_progress_data2, tv_progress_data3, tv_progress_data4;
	private TextView  tv_progress_name1, tv_progress_name2, tv_progress_name3, tv_progress_name4;
	private MutiProgress mutiProgress;
	private String type, id, producttype, loanid, ptype,red_id,red_type,couponMsg="";
	private boolean flag, isred=false,ishuo;
	private boolean nameauth, islogin;
	private String raiseEndDateMMdd;//项目募集时间（除年）
	private String openTimeMMdd;//开标时间月日
	private String countRateTime;//收益起算
	private String dueTime;//项目到期时间
	private String expectedPayTime;//预期回款时间
	private String raiseEndDateName;//项目募集名称
	private String countRateTimeName;//收益起算名称
	private String dueTimeName;//项目到期名称
	private String expectedPayTimeName;//预期回款名称
	private String currentTime;//预期回款名称
//	private CheckBox checkBox;
	private ImageView img_x2;
	private boolean flagcoupon = false, resultred = false,
			resultcoupon = false;
	private LinearLayout li_red,li_xx,li_l_tyue,li_dexterity;
	private DecimalFormat df = new DecimalFormat("###0.00");
	private DecimalFormat df2 = new DecimalFormat("###0");
	private DecimalFormat df3 = new DecimalFormat("###0.0");
	ProgressBar bar;
	private String [] data,text;
	SharedPreferences sha;
	private ImageView img_back;
	private String raisingratesId;
	AjaxParams params;
	private boolean flagred = false,raisingratesFlag=false;
	private double rate, ratecore,proportion,final_rate;
	private int qixian, month;
	private int maxAmount;
	private int minAmount;
	private boolean tishi_coupon=true;
	private int increaseNum, zhitou=0;// 投资增量
	private int remainAmount;// 剩余可投
	private int stepAmount;
	private boolean pass;
	private Button btn_earn;
	private TextView tv_v4_productdetails_day;
	private TextView tv_v4_productdetails_hour;
	private TextView tv_v4_productdetails_minutes;
	private TextView tv_v4_productdetails_second;
	long minute = 0;
	private int first_in=0;
	private LinearLayout li_date, li_fanxian;
	long second = 0;
	private CheckBox checkBox;
	TimerTask timerTask;
	private Timer timer;
	private RelativeLayout rl_youhui, rl_record,rl_my_center,rl_record2;
	private double availableGiftAmount, availableAmount;// 可用红包/余额
	private boolean isNewUesr;
	private ImageView img_nowork, img_share,img_xx,imageView1;
	private String shareurl;
	private RelativeLayout rl_back;
	private TextView tv_customer,tv_dexterity_remain;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
		setContentView(R.layout.product_detail);
		BbtApplication.getInstance().addActvity(this);
		IntentFilter mFilter = new IntentFilter();
	    mFilter.addAction("exit");
	    this.registerReceiver(myReceiver,mFilter);
		sk = (ProgressBar) findViewById(R.id.sk_progresss);
		btn = (Button) findViewById(R.id.dl_btn_pay);
		feature1 = (Button) findViewById(R.id.feature1);
		feature2 = (Button) findViewById(R.id.feature2);
		feature3 = (Button) findViewById(R.id.feature3);
		img_back = (ImageView) findViewById(R.id.img_back);
		img_x2=(ImageView)findViewById(R.id.img_x2);
		tv_yuan = (TextView) findViewById(R.id.tv_yuan);
		rl_detail = (RelativeLayout) findViewById(R.id.detail_rl_detail);
		rl_detail2 = (RelativeLayout) findViewById(R.id.detail_rl_detail2);
		tv_countinvest = (TextView) findViewById(R.id.tv_countinvest);
		tv_countinvest2=(TextView)findViewById(R.id.tv_countinvest2);
		rl_record = (RelativeLayout) findViewById(R.id.detail_rl_record);
		rl_record2 = (RelativeLayout) findViewById(R.id.detail_rl_record2);
		progress_text = (TextView) findViewById(R.id.progress_text);
		li_l_tyue=(LinearLayout)findViewById(R.id.li_l_yue);
		li_dexterity=(LinearLayout)findViewById(R.id.li_dexterity);
		product_remain = (TextView) findViewById(R.id.detail_Surplus_Money);
		product_money = (TextView) findViewById(R.id.detail_p_Money);
		imageView1=(ImageView)findViewById(R.id.imageView1);
//		tv_use_red = (TextView) findViewById(R.id.used_red);
		tv_progress_data1=(TextView)findViewById(R.id.tv_progress_data1);
		tv_progress_data2=(TextView)findViewById(R.id.tv_progress_data2);
		tv_progress_data3=(TextView)findViewById(R.id.tv_progress_data3);
		tv_progress_data4=(TextView)findViewById(R.id.tv_progress_data4);
		tv_progress_name1=(TextView)findViewById(R.id.tv_progress_name1);
		tv_progress_name2=(TextView)findViewById(R.id.tv_progress_name2);
		tv_progress_name3=(TextView)findViewById(R.id.tv_progress_name3);
		tv_progress_name4=(TextView)findViewById(R.id.tv_progress_name4);
		de_bbt_invest=(View)findViewById(R.id.de_bbt_invest);
		de_uplan_invest=(View)findViewById(R.id.de_uplan_invest);
		mutiProgress=(MutiProgress)findViewById(R.id.mp_1);	
		checkBox=(CheckBox)findViewById(R.id.check);
		sha = getSharedPreferences("coupon", MODE_PRIVATE);
		img_share = (ImageView) findViewById(R.id.img_share);
		space_view=(View)findViewById(R.id.space_view);
		space_view2=(View)findViewById(R.id.space_view2);
		li_xx=(LinearLayout)findViewById(R.id.li_xx);
		rl_comment=(RelativeLayout)findViewById(R.id.rl_comment);
		img_nowork = (ImageView) findViewById(R.id.iv_v4_nonetwork);
		rl_youhui = (RelativeLayout) findViewById(R.id.rl_youhui);
		product_rate = (TextView) findViewById(R.id.rate_of_return);
		tv_dexterity_remain=(TextView)findViewById(R.id.dexterity_remain);
		product_name = (TextView) findViewById(R.id.product_name);
		my_remain = (TextView) findViewById(R.id.my_remain);
		et_money = (EditText) findViewById(R.id.p_detail_et);
		li_progress=(LinearLayout)findViewById(R.id.li_progress);
		jiahao = (TextView) findViewById(R.id.jiahao);
		detail_add = (TextView) findViewById(R.id.detail_rateadd);
		rl_my_center=(RelativeLayout)findViewById(R.id.rl_my_center);
		waveView = (WaveView) findViewById(R.id.product_wave);
		sv = (PullToRefreshScrollView) findViewById(R.id.sv);
		user_yue = (TextView) findViewById(R.id.user_yue);
//		checkBox = (CheckBox) findViewById(R.id.red_check);
		li_date = (LinearLayout) findViewById(R.id.li_date);
		li_red = (LinearLayout) findViewById(R.id.li_red);
		li_fanxian = (LinearLayout) findViewById(R.id.li_fanxian);
		rl_youhui = (RelativeLayout) findViewById(R.id.rl_youhui);
		tv_youhui_date = (TextView) findViewById(R.id.youhui_date);
		tv_youhui_type = (TextView) findViewById(R.id.youhui_type);
		tv_tishi=(TextView)findViewById(R.id.tv_tishi);
		img_xx=(ImageView)findViewById(R.id.img_xx);
		tv_v4_productdetails_day = (TextView) findViewById(R.id.tv_v4_productdetails_day);
		tv_v4_productdetails_hour = (TextView) findViewById(R.id.tv_v4_productdetails_hour);
		tv_v4_productdetails_minutes = (TextView) findViewById(R.id.tv_v4_productdetails_minutes);
		tv_v4_productdetails_second = (TextView) findViewById(R.id.tv_v4_productdetails_second);
		tv_v4_pay_shouyi = (TextView) findViewById(R.id.tv_yuji);
		tv_v4_pay_redpackage = (TextView) findViewById(R.id.red_with);
		rl_back = (RelativeLayout) findViewById(R.id.rl_back);
		tv_customer = (TextView) findViewById(R.id.enterprise_tel);
		li_xx.setOnClickListener(this);
		tv_customer.setOnClickListener(this);
		rl_back.setOnClickListener(this);
		rl_detail.setOnClickListener(this);
		rl_youhui.setOnClickListener(this);
		img_nowork.setOnClickListener(this);
		li_dexterity.setOnClickListener(this);
		rl_detail2.setOnClickListener(this);
		rl_record2.setOnClickListener(this);
		img_back.setOnClickListener(this);
		rl_record.setOnClickListener(this);
		img_share.setOnClickListener(this);
		img_xx.setOnClickListener(this);
		li_l_tyue.setOnClickListener(this);
		btn.setOnClickListener(this);
		sv.setVisibility(View.GONE);
		btn.setVisibility(View.GONE);
		helper = new WaveHelper(waveView);
		helper.start();
		
//		Log.e("ss", getIntent().getStringExtra("type"));
		product_name.setText(getIntent().getStringExtra("name"));
		flag = getIntent().getBooleanExtra("flag", false);

		type = getIntent().getStringExtra("type");
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
	
	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		// TODO Auto-generated method stub
		ishuo=isChecked;
		myconmment();
	}
});
//		checkBox.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				if(checkBox.isChecked()&&!tv_tishi.equals("亲,您还有加息券未使用哦!")){
//					rl_comment.setVisibility(View.GONE);
//				}
//				if (checkBox.isChecked()) {
//					li_fanxian.setVisibility(View.VISIBLE);
//					flagred = true;
//					if (isNewUesr) {
//						if (!et_money.getText().toString().equals("")) {
//							double redpage = Double.valueOf(et_money.getText()
//									.toString()) * (proportion/100);
//							if (redpage > availableGiftAmount) {
//								redpage = availableGiftAmount;
//							}
//							tv_v4_pay_redpackage.setText(df.format(redpage)
//									+ "元");
//							if (getIntent().getStringExtra("type")
//									.equals("BBT")) {
//								double a = VoteCalculator
//										.getVoteCalculator_newuser(et_money
//												.getText().toString(), rate,
//												month);
//
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								tv_v4_pay_shouyi.setText(df.format(a) + "元");
//							} else {
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								double a = VoteCalculator
//										.getVoteCalculator_month(et_money
//												.getText().toString(), rate,
//												month);
//								tv_v4_pay_shouyi.setText(df.format(a) + "元");
//							}
//						} else {
//							tv_v4_pay_redpackage.setText("0.00" + "元");
//							tv_v4_pay_shouyi.setText("0.00" + "元");
//						}
//					} else {
//						if (!et_money.getText().toString().equals("")) {
//							double b = Double.valueOf(et_money.getText()
//									.toString()) * (proportion/100);
//							if (b < availableGiftAmount) {
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								tv_v4_pay_redpackage.setText(df.format(b) + "元");
//
//								if (getIntent().getStringExtra("type").equals(
//										"BBT")) {
//									double a = VoteCalculator
//											.getVoteCalculator_newuser(et_money
//													.getText().toString(),
//													rate, month);
//
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								} else {
//
//									double a = VoteCalculator
//											.getVoteCalculator_month(et_money
//													.getText().toString(),
//													rate, month);
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								}
//							} else {
//								if (getIntent().getStringExtra("type").equals(
//										"BBT")) {
//									double a = VoteCalculator
//											.getVoteCalculator_newuser(et_money
//													.getText().toString(),
//													rate, month);
//
//									DecimalFormat df = new DecimalFormat(
//											"######0.00");
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								} else {
//									DecimalFormat df = new DecimalFormat(
//											"######0.00");
//									double a = VoteCalculator
//											.getVoteCalculator_month(et_money
//													.getText().toString(),
//													rate, month);
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								}
//								tv_v4_pay_redpackage
//										.setText(availableGiftAmount + "元");
//							}
//						} else {
//							tv_v4_pay_redpackage.setText("0.00" + "元");
//							tv_v4_pay_shouyi.setText("0.00" + "元");
//						}
//					}
//
//				} else {
//					li_fanxian.setVisibility(View.INVISIBLE);
//					flagred = false;
//
//				}
//
//			}
//		});
		et_money.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				myconmment();
				
				
//				if(!s.toString().equals("")&&Long.parseLong(s.toString())-availableAmount>maxcurAmount&&ishuo){
//					rl_comment.setVisibility(View.VISIBLE);
//					tv_tishi.setText("智投宝转投单笔不超过50万元");
//				}else{
//					rl_comment.setVisibility(View.GONE);
//					btn.setText("马上投资");
//				}
				
				
//				Log.e("参数", et_money.getText().toString() + "---" + rate
//						+ month);
				if (flagcoupon) {
					if (resultred) {
						if (isNewUesr) {
							if (!et_money.getText().toString().equals("")) {
								if(getIntent().getStringExtra("type").equals("BBT")){
									if(red_type.equals("PERCENTAGE")){
										double redpage = Double.valueOf(et_money
												.getText().toString()) * (0.005);
										if (redpage > availableGiftAmount) {
											redpage = availableGiftAmount;
										}
										tv_v4_pay_redpackage.setText(df.format(redpage)
												+ "元");
									}else{
										
										double redpage = Double.valueOf(et_money
												.getText().toString()) * (proportion/100)/365*qixian;
										if (redpage > availableGiftAmount) {
											redpage = availableGiftAmount;
										}
										tv_v4_pay_redpackage.setText(df.format(redpage)
												+ "元");
									}
								}else{
									if(red_type.equals("PERCENTAGE")){
										double redpage = Double.valueOf(et_money
												.getText().toString()) * (0.005);
										if (redpage > availableGiftAmount) {
											redpage = availableGiftAmount;
										}
										tv_v4_pay_redpackage.setText(df.format(redpage)
												+ "元");
									}else{
										
										double redpage = Double.valueOf(et_money
												.getText().toString()) * (proportion/100)/365*month;
										if (redpage > availableGiftAmount) {
											redpage = availableGiftAmount;
										}
										tv_v4_pay_redpackage.setText(df.format(redpage)
												+ "元");
									}
								}
								
								if (getIntent().getStringExtra("type").equals(
										"BBT")) {
									double a = VoteCalculator
											.getVoteCalculator_newuser(et_money
													.getText().toString(),
													rate, month);

									DecimalFormat df = new DecimalFormat(
											"######0.00");
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								} else {
									DecimalFormat df = new DecimalFormat(
											"######0.00");
									double a = VoteCalculator
											.getVoteCalculator_month(et_money
													.getText().toString(),
													rate, month);
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								}
							} else {
								tv_v4_pay_redpackage.setText("0.00" + "元");
								tv_v4_pay_shouyi.setText("0.00" + "元");
							}
						} else {
							if (!et_money.getText().toString().equals("")) {
                                double b=0;
								if(getIntent().getStringExtra("type").equals("BBT")){
									if(red_type.equals("PERCENTAGE")){
										b = Double.valueOf(et_money
												.getText().toString()) * (0.005);
									}else{
										b = Double.valueOf(et_money
												.getText().toString()) * (proportion/100)/365*qixian;
									}
//									 b = Double.valueOf(et_money
//											.getText().toString()) * (proportion/100)/365*qixian;
									if (b > availableGiftAmount) {
										b = availableGiftAmount;
									}
									
								}else{
									if(red_type.equals("PERCENTAGE")){
										b = Double.valueOf(et_money
												.getText().toString()) * (0.005);

									}else{
										
										b = Double.valueOf(et_money
												.getText().toString()) * (proportion/100)/365*month;
									}
									if (b > availableGiftAmount) {
										b = availableGiftAmount;
									}
									
								}
								if (b < availableGiftAmount) {
									DecimalFormat df = new DecimalFormat(
											"######0.00");
									tv_v4_pay_redpackage.setText(df.format(b)
											+ "元");
									if (getIntent().getStringExtra("type")
											.equals("BBT")) {
										double a = VoteCalculator
												.getVoteCalculator_newuser(
														et_money.getText()
																.toString(),
														rate, month);

										tv_v4_pay_shouyi.setText(df.format(a)
												+ "元");
									} else {

										double a = VoteCalculator
												.getVoteCalculator_month(
														et_money.getText()
																.toString(),
														rate, month);
										tv_v4_pay_shouyi.setText(df.format(a)
												+ "元");
									}
								} else {
									if (getIntent().getStringExtra("type")
											.equals("BBT")) {
										double a = VoteCalculator
												.getVoteCalculator_newuser(
														et_money.getText()
																.toString(),
														rate, month);

										DecimalFormat df = new DecimalFormat(
												"######0.00");
										tv_v4_pay_shouyi.setText(df.format(a)
												+ "元");
									} else {
										DecimalFormat df = new DecimalFormat(
												"######0.00");
										double a = VoteCalculator
												.getVoteCalculator_month(
														et_money.getText()
																.toString(),
														rate, month);
										tv_v4_pay_shouyi.setText(df.format(a)
												+ "元");
									}
									tv_v4_pay_redpackage
											.setText(availableGiftAmount + "元");
								}
							} else {
								tv_v4_pay_redpackage.setText("0.00" + "元");
								tv_v4_pay_shouyi.setText("0.00" + "元");
							}
						}
					} else {
						if (isNewUesr) {
							if (!et_money.getText().toString().equals("")) {
								if (getIntent().getStringExtra("type").equals(
										"BBT")) {
									double a = VoteCalculator
											.getVoteCalculator_newuser(et_money
													.getText().toString(),
													rate, month);

									DecimalFormat df = new DecimalFormat(
											"######0.00");
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								} else {
									DecimalFormat df = new DecimalFormat(
											"######0.00");
									double a = VoteCalculator
											.getVoteCalculator_month(et_money
													.getText().toString(),
													rate, month);
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								}
							} else {
								tv_v4_pay_redpackage.setText("0.00" + "元");
								tv_v4_pay_shouyi.setText("0.00" + "元");
							}
						} else {
							if (!et_money.getText().toString().equals("")) {
								if (getIntent().getStringExtra("type").equals(
										"BBT")) {
									double a = VoteCalculator
											.getVoteCalculator_newuser(et_money
													.getText().toString(),
													rate, month);

									DecimalFormat df = new DecimalFormat(
											"######0.00");
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								} else {
									DecimalFormat df = new DecimalFormat(
											"######0.00");
									double a = VoteCalculator
											.getVoteCalculator_month(et_money
													.getText().toString(),
													rate, month);
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								}
							} else {
								tv_v4_pay_redpackage.setText("0.00" + "元");
								tv_v4_pay_shouyi.setText("0.00" + "元");
							}
						}
					}

					return;
				}

				if (resultred) {
					if (isNewUesr) {
						if (!et_money.getText().toString().equals("")) {
							if(getIntent().getStringExtra("type").equals("BBT")){
								if(red_type.equals("PERCENTAGE")){
									double redpage = Double.valueOf(et_money
											.getText().toString()) * (0.005);
									if (redpage > availableGiftAmount) {
										redpage = availableGiftAmount;
									}
									tv_v4_pay_redpackage.setText(df.format(redpage)
											+ "元");
								}else{
									
									double redpage = Double.valueOf(et_money
											.getText().toString()) * (proportion/100)/365*qixian;
									if (redpage > availableGiftAmount) {
										redpage = availableGiftAmount;
									}
									tv_v4_pay_redpackage.setText(df.format(redpage)
											+ "元");
								}
							}else{
								if(red_type.equals("PERCENTAGE")){
									double redpage = Double.valueOf(et_money
											.getText().toString()) * (0.005);
									if (redpage > availableGiftAmount) {
										redpage = availableGiftAmount;
									}
									tv_v4_pay_redpackage.setText(df.format(redpage)
											+ "元");
								}else{
									
									double redpage = Double.valueOf(et_money
											.getText().toString()) * (proportion/100)/365*month;
									if (redpage > availableGiftAmount) {
										redpage = availableGiftAmount;
									}
									tv_v4_pay_redpackage.setText(df.format(redpage)
											+ "元");
								}
							}
							if (getIntent().getStringExtra("type")
									.equals("BBT")) {
								double a = VoteCalculator
										.getVoteCalculator_newuser(et_money
												.getText().toString(), rate,
												month);

								DecimalFormat df = new DecimalFormat(
										"######0.00");
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							} else {
								DecimalFormat df = new DecimalFormat(
										"######0.00");
								double a = VoteCalculator
										.getVoteCalculator_month(et_money
												.getText().toString(), rate,
												month);
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							}
						} else {
							tv_v4_pay_redpackage.setText("0.00" + "元");
							tv_v4_pay_shouyi.setText("0.00" + "元");
						}

					} else {
						if (!et_money.getText().toString().equals("")) {
							 double b=0;
								if(getIntent().getStringExtra("type").equals("BBT")){
									if(red_type.equals("PERCENTAGE")){
										b = Double.valueOf(et_money
												.getText().toString()) * (0.005);
									}else{
										b = Double.valueOf(et_money
												.getText().toString()) * (proportion/100)/365*qixian;
									}
									 
									if (b > availableGiftAmount) {
										b = availableGiftAmount;
									}
									
								}else{
									if(red_type.equals("PERCENTAGE")){
										 b = Double.valueOf(et_money
													.getText().toString()) * (0.005);
									}else{
										 b = Double.valueOf(et_money
													.getText().toString()) * (proportion/100)/365*month;
									}
									
									if (b > availableGiftAmount) {
										b = availableGiftAmount;
									}
									
								}
							if (b < availableGiftAmount) {
								DecimalFormat df = new DecimalFormat(
										"######0.00");
								tv_v4_pay_redpackage.setText(df.format(b) + "元");
								if (getIntent().getStringExtra("type").equals(
										"BBT")) {
									double a = VoteCalculator
											.getVoteCalculator_newuser(et_money
													.getText().toString(),
													rate, month);

									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								} else {

									double a = VoteCalculator
											.getVoteCalculator_month(et_money
													.getText().toString(),
													rate, month);
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								}
							} else {
								if (getIntent().getStringExtra("type").equals(
										"BBT")) {
									double a = VoteCalculator
											.getVoteCalculator_newuser(et_money
													.getText().toString(),
													rate, month);

									DecimalFormat df = new DecimalFormat(
											"######0.00");
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								} else {
									DecimalFormat df = new DecimalFormat(
											"######0.00");
									double a = VoteCalculator
											.getVoteCalculator_month(et_money
													.getText().toString(),
													rate, month);
									tv_v4_pay_shouyi.setText(df.format(a) + "元");
								}
								tv_v4_pay_redpackage
										.setText(availableGiftAmount + "元");
							}
						} else {
							tv_v4_pay_redpackage.setText("0.00" + "元");
							tv_v4_pay_shouyi.setText("0.00" + "元");
						}
					}
				} else {
					if (isNewUesr) {
						if (!et_money.getText().toString().equals("")) {
							if (getIntent().getStringExtra("type")
									.equals("BBT")) {
								double a = VoteCalculator
										.getVoteCalculator_newuser(et_money
												.getText().toString(), rate,
												month);

								DecimalFormat df = new DecimalFormat(
										"######0.00");
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							} else {
								DecimalFormat df = new DecimalFormat(
										"######0.00");
								double a = VoteCalculator
										.getVoteCalculator_month(et_money
												.getText().toString(), rate,
												month);
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							}
						} else {
							tv_v4_pay_redpackage.setText("0.00" + "元");
							tv_v4_pay_shouyi.setText("0.00" + "元");
						}
					} else {
						if (!et_money.getText().toString().equals("")) {
							if (getIntent().getStringExtra("type")
									.equals("BBT")) {
								double a = VoteCalculator
										.getVoteCalculator_newuser(et_money
												.getText().toString(), rate,
												month);

								DecimalFormat df = new DecimalFormat(
										"######0.00");
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							} else {
								DecimalFormat df = new DecimalFormat(
										"######0.00");
								double a = VoteCalculator
										.getVoteCalculator_month(et_money
												.getText().toString(), rate,
												month);
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							}
						} else {
							tv_v4_pay_redpackage.setText("0.00" + "元");
							tv_v4_pay_shouyi.setText("0.00" + "元");
						}
					}
				}
//				if (product_name.getText().toString().indexOf("闪电标") == 0) {
//					if (isNewUesr) {
//						if (!et_money.getText().toString().equals("")) {
//							if(getIntent().getStringExtra("type").equals("BBT")){
//								if(red_type.equals("PERCENTAGE")){
//									double redpage = Double.valueOf(et_money
//											.getText().toString()) * (0.005);
//									if (redpage > availableGiftAmount) {
//										redpage = availableGiftAmount;
//									}
//									tv_v4_pay_redpackage.setText(df.format(redpage)
//											+ "元");
//								}else{
//									
//									double redpage = Double.valueOf(et_money
//											.getText().toString()) * (proportion/100)/365*qixian;
//									if (redpage > availableGiftAmount) {
//										redpage = availableGiftAmount;
//									}
//									tv_v4_pay_redpackage.setText(df.format(redpage)
//											+ "元");
//								}
//							}else{
//								if(red_type.equals("PERCENTAGE")){
//									double redpage = Double.valueOf(et_money
//											.getText().toString()) * (0.005);
//									if (redpage > availableGiftAmount) {
//										redpage = availableGiftAmount;
//									}
//									tv_v4_pay_redpackage.setText(df.format(redpage)
//											+ "元");
//								}else{
//									
//									double redpage = Double.valueOf(et_money
//											.getText().toString()) * (proportion/100)/365*month;
//									if (redpage > availableGiftAmount) {
//										redpage = availableGiftAmount;
//									}
//									tv_v4_pay_redpackage.setText(df.format(redpage)
//											+ "元");
//								}
//							}
//							if (getIntent().getStringExtra("type")
//									.equals("BBT")) {
//								double a = VoteCalculator
//										.getVoteCalculator_newuser(et_money
//												.getText().toString(), rate,
//												month);
//
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								tv_v4_pay_shouyi.setText(df.format(a) + "元");
//							} else {
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								double a = VoteCalculator
//										.getVoteCalculator_month(et_money
//												.getText().toString(), rate,
//												month);
//								tv_v4_pay_shouyi.setText(df.format(a) + "元");
//							}
//						} else {
//							tv_v4_pay_redpackage.setText("0.00" + "元");
//							tv_v4_pay_shouyi.setText("0.00" + "元");
//						}
//
//					} else {
//						if (!et_money.getText().toString().equals("")) {
//							
//							double b=0;
//								if(getIntent().getStringExtra("type").equals("BBT")){
//									if(red_type.equals("PERCENTAGE")){
//										b = Double.valueOf(et_money
//												.getText().toString()) * (0.005);
//									}else{
//										b = Double.valueOf(et_money
//												.getText().toString()) * (proportion/100)/365*qixian;
//									}
//									if (b > availableGiftAmount) {
//										b = availableGiftAmount;
//									}
//									
//								}else{
//									if(red_type.equals("PERCENTAGE")){
//										 b = Double.valueOf(et_money
//													.getText().toString()) * (0.005);
//									}else{
//										 b = Double.valueOf(et_money
//													.getText().toString()) * (proportion/100)/365*month;
//									}
//									if (b > availableGiftAmount) {
//										b = availableGiftAmount;
//									}
//									
//								}
//							if (b < availableGiftAmount) {
//								DecimalFormat df = new DecimalFormat(
//										"######0.00");
//								tv_v4_pay_redpackage.setText(df.format(b) + "元");
//								if (getIntent().getStringExtra("type").equals(
//										"BBT")) {
//									double a = VoteCalculator
//											.getVoteCalculator_newuser(et_money
//													.getText().toString(),
//													rate, month);
//
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								} else {
//
//									double a = VoteCalculator
//											.getVoteCalculator_month(et_money
//													.getText().toString(),
//													rate, month);
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								}
//							} else {
//								if (getIntent().getStringExtra("type").equals(
//										"BBT")) {
//									double a = VoteCalculator
//											.getVoteCalculator_newuser(et_money
//													.getText().toString(),
//													rate, month);
//
//									DecimalFormat df = new DecimalFormat(
//											"######0.00");
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								} else {
//									DecimalFormat df = new DecimalFormat(
//											"######0.00");
//									double a = VoteCalculator
//											.getVoteCalculator_month(et_money
//													.getText().toString(),
//													rate, month);
//									tv_v4_pay_shouyi.setText(df.format(a) + "元");
//								}
//								tv_v4_pay_redpackage
//										.setText(availableGiftAmount + "元");
//							}
//						} else {
//							tv_v4_pay_redpackage.setText("0.00" + "元");
//							tv_v4_pay_shouyi.setText("0.00" + "元");
//						}
//					}
//					Log.e("天数", month + "");
//				}
				 Log.e("提示", "余额"+availableAmount+"活期"+ishuo+""+islogin+nameauth+(ishuo==false)+curAmount);
				 Log.e("状态",  (!s.toString().equals("")
							&& availableAmount < Long.parseLong(s.toString())&&(ishuo==false)
							&& islogin && nameauth) +"");
				
			}

		});
		loanid = getIntent().getStringExtra("id");
//		loanid="003530fa-ad6e-11e6-878f-7baef4c0e22e";
		Log.e("id", loanid);
		if (getIntent().getStringExtra("type").equals("BBT")) {
			feature1.setText(getIntent().getStringExtra("method"));

		} else {
			

			
			

		}
		userinfo();
		initData(true);

		sk.setEnabled(false);
	}
	MyReceiver myReceiver = new MyReceiver(){
        @Override
        public void onReceive(Context context, Intent intent) {
            finish();
        }
    };
	Handler handler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			if (msg.what == 0) {
				if (minute == 0) {
					if (second == 0) {

						if (timer != null) {
							timer.cancel();
							timer = null;
						}
						if (timerTask != null) {
							timerTask = null;
						}
					} else {
						second--;
						if (second >= 10) {
							// timeView.setText("0"+minute + ":" + second);
							tv_v4_productdetails_minutes.setText(minute + "");
							tv_v4_productdetails_second.setText(second + "");
						} else {
							// timeView.setText("0"+minute + ":0" + second);
							tv_v4_productdetails_minutes.setText("0" + minute);
							tv_v4_productdetails_second.setText("0" + second);
						}
					}
				} else {
					if (second == 0) {
						second = 59;
						minute--;
						if (minute >= 10) {
							// timeView.setText(minute + ":" + second);
							tv_v4_productdetails_minutes.setText(minute + "");
							tv_v4_productdetails_second.setText(second + "");
						} else {
							// timeView.setText("0"+minute + ":" + second);
							tv_v4_productdetails_minutes.setText("0" + minute);
							tv_v4_productdetails_second.setText(second + "");
						}
					} else {
						second--;
						if (second >= 10) {
							if (minute >= 10) {
								// timeView.setText(minute + ":" + second);
								tv_v4_productdetails_minutes.setText(minute
										+ "");
								tv_v4_productdetails_second
										.setText(second + "");
							} else {
								// timeView.setText("0"+minute + ":" + second);
								tv_v4_productdetails_minutes.setText("0"
										+ minute);
								tv_v4_productdetails_second
										.setText(second + "");
							}
						} else {
							if (minute >= 10) {
								// timeView.setText(minute + ":0" + second);
								tv_v4_productdetails_minutes.setText(minute
										+ "");
								tv_v4_productdetails_second.setText("0"
										+ second);
							} else {
								// timeView.setText("0"+minute + ":0" + second);
								tv_v4_productdetails_minutes.setText("0"
										+ minute);
								tv_v4_productdetails_second.setText("0"
										+ second);

							}
						}
					}
				}

			}
		}
	};
   private void myconmment(){
	   if(useFundAmountInvestFlag==0){
			
			if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>curAmount&& islogin && nameauth){
if(curAmount==0){
					
					rl_comment.setVisibility(View.VISIBLE);
					tv_tishi.setText("特权时间过后即可投资");
				}else{
					if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>maxcurAmount){
						rl_comment.setVisibility(View.VISIBLE);
						tv_tishi.setText("智投宝转投单笔不超过"+(df2.format(maxcurAmount/10000))+"万元");
						
					}else{
						rl_comment.setVisibility(View.VISIBLE);
						if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>curAmount){
							tv_tishi.setText("智投宝余额不足");
							
						}else{
							
							rl_comment.setVisibility(View.GONE);
							btn.setText("马上投资");
						}
					}
					
				}
			}else{
				if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>maxcurAmount){
					rl_comment.setVisibility(View.VISIBLE);
					tv_tishi.setText("智投宝转投单笔不超过"+(df2.format(maxcurAmount/10000))+"万元");
					
				}else{
					rl_comment.setVisibility(View.VISIBLE);
					if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>curAmount){
						tv_tishi.setText("智投宝余额不足");
						
					}else{
						
						rl_comment.setVisibility(View.GONE);
						btn.setText("马上投资");
					}
				}
			}
			
			
		}else{
			if(ishuo){
				if (!et_money.getText().toString().equals("")
						&&ishuo&&Long.parseLong(et_money.getText().toString())>(curAmount+availableAmount)
						&& islogin && nameauth) {
					     if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount&&curAmount>=maxcurAmount){
					    	 rl_comment.setVisibility(View.VISIBLE);
					    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
					    	 btn.setText("马上投资");
					}else{
						 rl_comment.setVisibility(View.VISIBLE);
				    	 tv_tishi.setText("余额不足,请充值!");
				    	 btn.setText("余额不足,请充值!");
				    	 
					}
					
				} else {
					if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount){
				    	 rl_comment.setVisibility(View.VISIBLE);
				    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
				    	 btn.setText("马上投资");
				}else{
					rl_comment.setVisibility(View.GONE);
					btn.setText("马上投资");
			    	 
				}
					
				}
			}else{
				if (!et_money.getText().toString().equals("")
						&& availableAmount < Long.parseLong(et_money.getText().toString())&&(ishuo==false)
						&& islogin && nameauth) {
					if(curAmount>0){
						rl_comment.setVisibility(View.VISIBLE);
						tv_tishi.setText("可用余额不足，请充值或选择智投宝余额转投");
						btn.setText("余额不足,请充值!");
						Log.e("提示", "可用余额不足，请充值或选择智投宝余额转投");
					}else{
						rl_comment.setVisibility(View.GONE);
						btn.setText("余额不足,请充值!");
					}
	        
				} else {
					btn.setText("马上投资");
				}
			}
		}
   }
	private void initData(final boolean isshow) {
		// TODO Auto-generated method stub
		if (getIntent().getStringExtra("type").equals("BBT")) {
 
		} else {
			params = new AjaxParams();

			params.put("flagFresh", flag + "");
		}
		VolleryUtil volleryUtil = new VolleryUtil() {

			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				sv.setVisibility(View.VISIBLE);
				btn.setVisibility(View.VISIBLE); 
				Log.e("直投详情", jsonObject.toString());
				ToJSON.initData(jsonObject.toString());
				if (getIntent().getStringExtra("type").equals("BBT")) {
					JSONObject json1 = jsonObject.optJSONObject("data");
					JSONObject json2 = json1.optJSONObject("loanRequest");
					JSONObject json3 = json1.optJSONObject("loan");
					li_progress.setVisibility(View.GONE);
					space_view.setVisibility(View.GONE);
					space_view2.setVisibility(View.GONE);
					curAmount=json1.optDouble("curAmount");
					maxcurAmount=json1.optDouble("maxTransferInvestAmount");
							if(!json1.optString("curAmount").equals("")){
								
								tv_dexterity_remain.setText(df.format(Double.parseDouble(json1.optString("curAmount"))));
							}
					sv.setVisibility(View.VISIBLE);
					useFundAmountInvestFlag=json1.optInt("useFundAmountInvestFlag");
					de_bbt_invest.setVisibility(View.VISIBLE);
					img_nowork.setVisibility(View.GONE);
					if(!jsonObject.optString("data").equals("null")){
					isred=true;
					useFundAmountInvestFlag=json1.optInt("useFundAmountInvestFlag");
					li_date.setVisibility(View.VISIBLE);
					zhitou = 1;
					if(useFundAmountInvestFlag==0){
						user_yue.setTextColor(Color.GRAY);
						my_remain.setTextColor(Color.GRAY);
						checkBox.setVisibility(View.GONE);
						ishuo=true;
					}
					
//					month = json1.optInt("month") * 30 + json1.optInt("day");
					month=json1.optInt("loanRealDays");
//					qixian = json2.optInt("years") * 365
//							+ json2.optInt("months") * 30
//							+ json2.optInt("days");
					qixian=json1.optInt("loanRealDays");
					minAmount = json2.optInt("minAmount");
					rate = (json2.optDouble("rate")) / 100d;
					final_rate=(json2.optDouble("rate")) / 100d;
					if(isshow){						
						ratecore = (json2.optDouble("rateAdd") + json2
								.optDouble("rate")) / 100d;
						Log.e("加息", "1次"+ratecore);
						
					}
					stepAmount = json2.optInt("stepAmount");
					remainAmount = json1.optInt("remainAmount");
					increaseNum = json2.optInt("stepAmount");
					id = json3.optString("loanId");
					feature2.setText(df2.format(Double.parseDouble(json1.optString("minAmount"))) + "元" + "起购");
					if (json1.optInt("month") == 0) {
						feature3.setText(json1.optString("day") + "天");

					} else {
						if (json1.optInt("day") == 0) {

							feature3.setText(json1.optString("month") + "个月");
						} else {
							feature3.setText(json1.optString("month") + "个月"
									+ json1.optInt("day") + "天");
						}

					}
					couponMsg=json1.optString("couponMsg");
                    if(img_xx.getVisibility()==View.GONE){
						
						tv_youhui_type.setText(json1.optString("couponMsg"));
						imageView1.setVisibility(View.VISIBLE);
					}else{
						
					}
//ToJSON.initData(jsonObject.toString());
					et_money.setHint(df2.format(Double.parseDouble(json1.optString("minAmount"))) + "元起购");
//					if (product_name.getText().toString().indexOf("闪电标") == 0) {
//						rl_youhui.setVisibility(View.GONE);
//					} else {
//						rl_youhui.setVisibility(View.VISIBLE);
//					}
					rl_youhui.setVisibility(View.VISIBLE);
					product_remain.setText(df2.format(Double.parseDouble(json1
							.optString("remainAmount"))));
					product_money.setText(df2.format(Double.parseDouble(json1
							.optString("amount"))));
					if (json1.optInt("rateAdd") == 0) {
						product_rate.setText(df.format(Double.parseDouble(json1
								.optString("originRate")) / 100) );
						jiahao.setVisibility(View.GONE);
						detail_add.setVisibility(View.GONE);
					} else {
						product_rate.setText(df.format(Double.parseDouble(json1
								.optString("originRate")) / 100) );
						jiahao.setVisibility(View.VISIBLE);
						detail_add.setVisibility(View.VISIBLE);
						detail_add.setText(df.format(Double.parseDouble(json1
								.optString("rateAdd")) / 100) + "%");
					}
					tv_countinvest.setText(json1.optString("investedNumber")
							);
					tv_countinvest2
					.setText(json1.optString("countInvest") );
					sk.setProgress(Integer.parseInt(String.valueOf(
							json1.optDouble("progress") * 10).replace(".0", "")));
					progress_text.setText(df3.format(Double.parseDouble(json1.optString("progress"))) + "%");
					long now = json1.optLong("nowTime");
					long end = json1.optLong("endTime");
					long keyong = end - now;
					if (keyong > 0 && json1.optInt("remainAmount") > 0) {
						btn.setBackgroundResource(R.drawable.my_button);
						btn.setText("马上投资");
//						checkBox.setEnabled(true);
						long day = keyong / (24 * 60 * 60 * 1000);
						long hour = (keyong / (60 * 60 * 1000) - day * 24);
						long min = ((keyong / (60 * 1000)) - day * 24 * 60 - hour * 60);
						@SuppressWarnings("unused")
						long s = (keyong / 1000 - day * 24 * 60 * 60 - hour
								* 60 * 60 - min * 60);
						// long ms = (keyong - day * 24 * 60 * 60 * 1000 - hour*
						// 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
						// System.out.println(day + "天" + hour + "小时" + min +
						// "分"+ s + "秒" + ms + "毫秒");
						tv_v4_productdetails_day.setText(day + "");
						tv_v4_productdetails_hour.setText(hour + "");
						tv_v4_productdetails_minutes.setText(min + "");
						tv_v4_productdetails_second.setText("" + s);
						minute = min;
						second = s;
						timerTask = new TimerTask() {

							@Override
							public void run() {
								Message msg = new Message();
								msg.what = 0;
								handler.sendMessage(msg);
							}
						};
                        
                        	 if(timer==null){
                        		 
                        		 timer = new Timer();
                        		 timer.schedule(timerTask, 0, 1000);
                        	 }
                         

					} else {
						tv_v4_productdetails_day.setText("0");
						tv_v4_productdetails_hour.setText("0");
						tv_v4_productdetails_minutes.setText("0");
						tv_v4_productdetails_second.setText("0");
						
//						checkBox.setEnabled(false);
					}
					}else{
						btn.setEnabled(false);
					}
					if(useFundAmountInvestFlag==1){
						if (!et_money.getText().toString().equals("")
								&& islogin && nameauth) {
							if(ishuo){
								if (!et_money.getText().toString().equals("")
										&&ishuo&&Long.parseLong(et_money.getText().toString())>(curAmount+availableAmount)
										&& islogin && nameauth) {
									     if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount&&curAmount>=maxcurAmount){
									    	 rl_comment.setVisibility(View.VISIBLE);
									    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
									    	 btn.setText("马上投资");
									}else{
										 rl_comment.setVisibility(View.VISIBLE);
								    	 tv_tishi.setText("余额不足,请充值!");
								    	 btn.setText("余额不足,请充值!");
								    	 
									}
									
								} else {
									if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount){
								    	 rl_comment.setVisibility(View.VISIBLE);
								    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
								    	 btn.setText("马上投资");
								}else{
									rl_comment.setVisibility(View.GONE);
									btn.setText("马上投资");
							    	 
								}
									
								}
							}else{
								if (!et_money.getText().toString().equals("")
										&& availableAmount < Long.parseLong(et_money.getText().toString())&&(ishuo==false)
										&& islogin && nameauth) {
									if(curAmount>0){
										rl_comment.setVisibility(View.VISIBLE);
										tv_tishi.setText("可用余额不足，请充值或选择智投宝余额转投");
										btn.setText("余额不足,请充值!");
										Log.e("提示", "可用余额不足，请充值或选择智投宝余额转投");
									}else{
										rl_comment.setVisibility(View.GONE);
										btn.setText("余额不足,请充值!");
									}
					        
								} else {
									btn.setText("马上投资");
								}
							}

						} else {
							if(json3.optString("status").equals("OPENED")){
								btn.setText("马上投资");
								
							}else if(json3.optString("status").equals("SETTLED")){
								btn.setText(json1.optString("status"));
								btn.setBackgroundResource(R.drawable.btn_unclick);
								btn.setEnabled(false);
								et_money.setEnabled(false);
							}else{
								btn.setText(json1.optString("status"));
								btn.setBackgroundResource(R.drawable.btn_unclick);
								btn.setEnabled(false);
								et_money.setEnabled(false);
							}
						}
					}else{
						if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>curAmount&& islogin && nameauth){
							if(curAmount==0){
												
												rl_comment.setVisibility(View.VISIBLE);
												tv_tishi.setText("特权时间过后即可投资");
											}else{
												if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>maxcurAmount){
													rl_comment.setVisibility(View.VISIBLE);
													if(Long.parseLong(et_money.getText().toString())>(availableAmount+curAmount)){
														tv_tishi.setText("余额不足,请充值!");
														btn.setText("余额不足,请充值!");
													}else{
														
														tv_tishi.setText("智投宝转投单笔不超过"+(df2.format(maxcurAmount/10000))+"万元");
														btn.setText("马上投资");
													}
												}else{
													rl_comment.setVisibility(View.VISIBLE);
													tv_tishi.setText("智投宝余额不足，请重新输入");
												}
												
											}
										}else{
											if(json3.optString("status").equals("OPENED")){
												btn.setText("马上投资");
												
											}else if(json3.optString("status").equals("SETTLED")){
												btn.setText(json1.optString("status"));
												btn.setBackgroundResource(R.drawable.btn_unclick);
												btn.setEnabled(false);
												et_money.setEnabled(false);
											}else{
												btn.setText(json1.optString("status"));
												btn.setBackgroundResource(R.drawable.btn_unclick);
												btn.setEnabled(false);
												et_money.setEnabled(false);
											}
										}
					}
					
				} else {
  
					sv.setVisibility(View.VISIBLE);
					img_nowork.setVisibility(View.GONE);
					btn.setVisibility(View.VISIBLE); 
					if(!jsonObject.optString("data").equals("null")){
						
					de_uplan_invest.setVisibility(View.VISIBLE);
					JSONObject json1 = jsonObject.optJSONObject("data");
					JSONObject json2 = json1.optJSONObject("user");
					flagcoupon = json1.optBoolean("flagCoupon");
					isred = json1.optBoolean("flagRedpack");
					Log.e("uplan", jsonObject.toString());
					id=json1.optString("productId");
					couponMsg=json1.optString("couponMsg");
					raiseEndDateName=json1.optString("raiseEndDateName");//募集截止名称
					countRateTimeName=json1.optString("countRateTimeName");//收益起算名称
					dueTimeName=json1.optString("dueTimeName");//项目到期名称
					expectedPayTimeName=json1.optString("expectedPayTimeName");//预期回款名称
					raiseEndDateMMdd=json1.optString("raiseEndDateMMdd");//募集年月日
					openTimeMMdd=json1.optString("openTimeMMdd");//开始年月日
					countRateTime=json1.optString("countRateTime");//收益起算时间
					dueTime=json1.optString("dueTime");//项目到期时间
					expectedPayTime=json1.optString("expectedPayTime");//预期回款时间
					currentTime=json1.optString("currentTime");
					
					data=new String []{openTimeMMdd+"至"+raiseEndDateMMdd,countRateTime,dueTime,expectedPayTime};
					text=new String []{raiseEndDateName,countRateTimeName,dueTimeName,expectedPayTimeName};
					tv_progress_data1.setText(data[0]);
					tv_progress_data2.setText(data[1]);
					tv_progress_data3.setText(data[2]);
					tv_progress_data4.setText(data[3]);
					tv_progress_name1.setText(text[0]);
					tv_progress_name2.setText(text[1]);
					tv_progress_name3.setText(text[2]);
					tv_progress_name4.setText(text[3]);
					LogUtils.e("4", expectedPayTime.compareTo(currentTime)+"");
					LogUtils.e("3", dueTimeName.compareTo(currentTime)+"");
					LogUtils.e("2", countRateTime.compareTo(currentTime)+"");
					if(json1.optString("status").equals("COLLECTING")){
						btn.setEnabled(true);
						
						btn.setBackgroundResource(R.drawable.my_button);
					}else{
						btn.setText(json1.optString("statusName"));
						et_money.setEnabled(false);
						btn.setBackgroundResource(R.drawable.btn_unclick);
						btn.setEnabled(false);
					}
//					if(first_in==0){
						
						if(currentTime.compareTo(expectedPayTime)>=0){
							mutiProgress.setCurnodeNo(3);
							changeTextColor4();
						}else if(currentTime.compareTo(dueTimeName)>=0){
							mutiProgress.setCurnodeNo(2);
							changeTextColor3();
						}else if(currentTime.compareTo(countRateTime)>=0){
							mutiProgress.setCurnodeNo(1);
							changeTextColor2();
						}else{
							mutiProgress.setCurnodeNo(0);
							changeTextColor1();
						}
						first_in+=1;
						Log.e("详情", first_in+"");
//					}
					
					
					if(img_xx.getVisibility()==View.GONE){
						if(arg3==2){
							tv_youhui_type.setText("去使用");
						}else{
							
							tv_youhui_type.setText(json1.optString("couponMsg"));
						}
						imageView1.setVisibility(View.VISIBLE);
					}else{
						
					}
					
					if(json2!=null){
						raisingratesFlag=json1.optBoolean("raisingratesFlag");
						if(!json2.optString("curAmount").equals("")){
							
							tv_dexterity_remain.setText(df.format(Double.parseDouble(json2.optString("curAmount"))));
						}
						curAmount=json2.optDouble("curAmount");
						useFundAmountInvestFlag=json2.optInt("useFundAmountInvestFlag");
//						useFundAmountInvestFlag=1;
//						useFundAmountInvestFlag=0;
						maxcurAmount=json2.optDouble("maxTransferInvestAmount");
						if(useFundAmountInvestFlag==0){
							user_yue.setTextColor(Color.GRAY);
							my_remain.setTextColor(Color.GRAY);
							checkBox.setVisibility(View.GONE);
							ishuo=true;
						}
					}else{
						li_dexterity.setVisibility(View.INVISIBLE);
						li_l_tyue.setVisibility(View.GONE);
					}
					
					if (flagcoupon||isred) {
						
						rl_youhui.setVisibility(View.VISIBLE);

					} else {
						
						rl_youhui.setVisibility(View.GONE);
					}
//					if (!isred && !flagcoupon) {
//						
//						rl_youhui.setVisibility(View.GONE);
//					} 
					
					if (json1.optString("status").equals("FINISHED")) {
						if(json1.optString("type").equals("FIXED_DEPOSIT_3")||json1.optString("type").equals("MONTH_WIN")){
							btn.setText(json1.optString("isFlagFill"));
						}else{							
							btn.setText("已售罄");
						}
						et_money.setEnabled(false);
						btn.setEnabled(false);
//						checkBox.setEnabled(false);
						btn.setBackgroundResource(R.drawable.btn_unclick);
					} else { 
						if(useFundAmountInvestFlag==0){
							
							if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>curAmount&&islogin&&nameauth){
			if(curAmount==0){
									
									rl_comment.setVisibility(View.VISIBLE);
									tv_tishi.setText("特权时间过后即可投资");
								}else{
									if(!et_money.getText().toString().equals("")&&Long.parseLong(et_money.getText().toString())>maxcurAmount){
										rl_comment.setVisibility(View.VISIBLE);
										if(Long.parseLong(et_money.getText().toString())>curAmount){
											tv_tishi.setText("智投宝转投单笔不超过"+df2.format(maxcurAmount/10000)+"万元");
										}else{
											
											tv_tishi.setText("智投宝余额不足");
										}
									}else{
										rl_comment.setVisibility(View.VISIBLE);
										tv_tishi.setText("智投宝余额不足，请重新输入");
									}
									
								}
							}else{
								rl_comment.setVisibility(View.GONE);
								if(json1.optString("status").equals("COLLECTING")){
									btn.setEnabled(true);
									
									btn.setBackgroundResource(R.drawable.my_button);
								}else{
									btn.setText(json1.optString("statusName"));
									et_money.setEnabled(false);
									btn.setBackgroundResource(R.drawable.btn_unclick);
									btn.setEnabled(false);
								}
							}
							
							
						}else{
							if(ishuo){
								if (!et_money.getText().toString().equals("")
										&&ishuo&&Long.parseLong(et_money.getText().toString())>(curAmount+availableAmount)
										&& islogin && nameauth) {
									     if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount&&curAmount>=maxcurAmount){
									    	 rl_comment.setVisibility(View.VISIBLE);
									    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
									    	 btn.setText("马上投资");
									}else{
										 rl_comment.setVisibility(View.VISIBLE);
								    	 tv_tishi.setText("余额不足,请充值!");
								    	 btn.setText("余额不足,请充值!");
								    	 
									}
									
								} else {
									if(!et_money.getText().toString().equals("")&&(Long.parseLong(et_money.getText().toString())-availableAmount)>maxcurAmount){
								    	 rl_comment.setVisibility(View.VISIBLE);
								    	 tv_tishi.setText("智投宝转投单笔不能超过"+df2.format(maxcurAmount/10000)+"万元");
								    	 if(json1.optString("status").equals("COLLECTING")){
												btn.setEnabled(true);
												
												btn.setBackgroundResource(R.drawable.my_button);
											}else{
												btn.setText(json1.optString("statusName"));
												et_money.setEnabled(false);
												btn.setBackgroundResource(R.drawable.btn_unclick);
												btn.setEnabled(false);
											}
								}else{
									rl_comment.setVisibility(View.GONE);
									if(json1.optString("status").equals("COLLECTING")){
										btn.setEnabled(true);
										
										btn.setBackgroundResource(R.drawable.my_button);
									}else{
										btn.setText(json1.optString("statusName"));
										et_money.setEnabled(false);
										btn.setBackgroundResource(R.drawable.btn_unclick);
										btn.setEnabled(false);
									}
							    	 
								}
									
								}
							}else{
								if (!et_money.getText().toString().equals("")
										&& availableAmount < Long.parseLong(et_money.getText().toString())&&(ishuo==false)
										&& islogin && nameauth) {
									if(curAmount>0){
										rl_comment.setVisibility(View.VISIBLE);
										tv_tishi.setText("可用余额不足，请充值或选择智投宝余额转投");
										btn.setText("余额不足,请充值!");
										Log.e("提示", "可用余额不足，请充值或选择智投宝余额转投");
									}else{
										rl_comment.setVisibility(View.GONE);
										btn.setText("余额不足,请充值!");
									}
					        
								} else {
									if(json1.optString("status").equals("COLLECTING")){
										btn.setEnabled(true);
										
										btn.setBackgroundResource(R.drawable.my_button);
									}else{
										btn.setText(json1.optString("statusName"));
										et_money.setEnabled(false);
										btn.setBackgroundResource(R.drawable.btn_unclick);
										btn.setEnabled(false);
									}
								}
							}
						}
						
//						checkBox.setEnabled(true);
					}
					li_date.setVisibility(View.GONE);
					id = json1.optString("productId");
					feature3.setText(json1.optString("countRateType"));
					feature2.setText(df2.format(Double.parseDouble(json1.optString("minAmount"))) + "元" + "起购");
					feature1.setText("期限"+json1.optString("closourePeriod") + "天");
					if (flag) {
						feature2.setText("限投"
								+ df2.format(Double.parseDouble(json1
										.optString("maxAmount"))) + "元");

					}
					month = json1.optInt("days");
					et_money.setHint(df2.format(Double.parseDouble(json1.optString("minAmount"))) + "元起购");
					product_remain.setText(df2.format(Double.parseDouble(json1
							.optString("remainAmount"))));
					product_money.setText(df2.format(Double.parseDouble(json1
							.optString("amount"))));
					zhitou = 0;
					minAmount = json1.optInt("minAmount");
					increaseNum = json1.optInt("increaseNum");
					maxAmount = json1.optInt("maxAmount");
					rate = Double.parseDouble(json1.optString("rate"));
					final_rate= Double.parseDouble(json1.optString("rate"));
					ratecore = Double.parseDouble(json1.optString("rate"));
					if (json1.optDouble("rateAdd") == 0) {
						product_rate.setText(df.format(Double.parseDouble(json1
								.optString("rate"))));
						jiahao.setVisibility(View.GONE);
						detail_add.setVisibility(View.GONE);
					} else {
						product_rate
								.setText(df.format(Double.parseDouble(json1
										.optString("rate"))-Double.parseDouble(json1
												.optString("rateAdd"))
										)
										);
						jiahao.setVisibility(View.VISIBLE);
						detail_add.setVisibility(View.VISIBLE);
						detail_add.setText(df.format(Double.parseDouble(json1
								.optString("rateAdd"))) + "%");
					}
					if (flag) {
						product_rate.setText(df.format(Double.parseDouble(json1
								.optString("rate"))) );
						jiahao.setVisibility(View.VISIBLE);
						detail_add.setVisibility(View.VISIBLE);
						detail_add.setText(df.format(Double.parseDouble(json1
								.optString("redPacketRate"))) + "%" + "新人加息券");
						if(json1.optDouble("raisingRate")==0){
							
						}else{
							if(up==0&&arg3!=2){
								result=1;
								rate=rate+json1.optDouble("raisingRate");
								resultcoupon = true;
								raisingratesId = json1.optString("raisingId");
								Editor editor = sha.edit();
								
								editor.putString("check", raisingratesId);
								editor.putString("type", "INTEREST_RATES");
								editor.commit();
								Log.e("up", rate+"");
							}
						}
					}
					
					tv_countinvest
							.setText(json1.optString("countInvest") );
					tv_countinvest2
					.setText(json1.optString("countInvest") );
					sk.setProgress(Integer.parseInt(
							df2.format(json1.optDouble("progress")) )*10);
					Log.e("ss", getIntent().getStringExtra("type"));
					progress_text.setText(df3.format(Double.parseDouble(json1.optString("progress"))) + "%");

				}else{
					btn.setEnabled(false);
				}
					
				}
			}

			@Override
			public void onError() {
				// TODO Auto-generated method stub
				sv.setVisibility(View.GONE);
				img_nowork.setVisibility(View.VISIBLE);
				Toast.makeText(DetailsActivity.this, "请求失败   请检查网络设置", 2000)
						.show();
			}
		};
		volleryUtil.setRequestMethod(0);
		volleryUtil.setShow(true);
		volleryUtil.setHeaders("token", getToken());
		if (getIntent().getStringExtra("type").equals("BBT")) {
			volleryUtil.execute(DetailsActivity.this, Constant.URL
					+ "/apiLoan/loan/" + loanid, "");
			LogUtils.e("aaaaa", Constant.URL + "/apiLoan/loan/" + loanid);
		} else {
//			volleryUtil.execute(DetailsActivity.this, Constant.URL
//					+ "/api/v5/product/uplanDetail/" + loanid,
//					"?" + params.toString());
					volleryUtil.execute(DetailsActivity.this, Constant.URL
							+ "/api/v6/render/assetDetail/"+type+ "/"+loanid,"")
							;
			LogUtils.e("aaaaa", Constant.URL + "/api/v5/product/uplanDetail/"
					+ loanid);
		}
	}
private void changeTextColor4(){
	tv_progress_data1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data2.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data3.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data4.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name2.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name3.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name4.setTextColor(Color.parseColor("#3478C2"));
//	img_x2.setImageResource(R.drawable.x1);
}
private void changeTextColor3(){
	tv_progress_data1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data2.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data3.setTextColor(Color.parseColor("#3478C2"));
	
	tv_progress_name1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name2.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name3.setTextColor(Color.parseColor("#3478C2"));
}
private void changeTextColor2(){
	tv_progress_data1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_data2.setTextColor(Color.parseColor("#3478C2"));
	
	
	tv_progress_name1.setTextColor(Color.parseColor("#3478C2"));
	tv_progress_name2.setTextColor(Color.parseColor("#3478C2"));
	
}
private void changeTextColor1(){
	tv_progress_data1.setTextColor(Color.parseColor("#3478C2"));
	
	
	
	tv_progress_name1.setTextColor(Color.parseColor("#3478C2"));
	
	
}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if (sha != null) {
			Editor editor = sha.edit();
			editor.clear();
			editor.commit();
		}
		helper.cancel();

		BbtApplication.getInstance().removeActvity(this);

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = null;
		switch (v.getId()) {
		case R.id.detail_rl_detail:
			intent = new Intent(DetailsActivity.this, V4WebViewActivity.class);
			intent.putExtra("title", "了解" + product_name.getText().toString());
//			if (type.equals("MONTH_WIN")) {
//				intent.putExtra("url",
//						"/v3/product/yyDescribe?flagFresh=false&type=MONTH_WIN&app=true");
//			} else if (type.equals("RECYCLE_INTEREST")) {
//				intent.putExtra("url",
//						"/v3/product/flDescribe?flagFresh=false&type=RECYCLE_INTEREST&app=true");
			 if(zhitou==0){
				 intent.putExtra("url", "/v3/product/newProDesc?type=" + type+"&productId="+id+"&app=true");
			} else if (zhitou == 1) {
				intent.putExtra("url", "/v3/product/loanDescribe?id=" + id+"&app=true");
			} else {
				String star = product_name.toString().substring(
						product_name.length() - 1, product_name.length());
				if (flag) {
					intent.putExtra("url",
							"/v3/product/newDescribe?flagFresh=true&app=true&type="
									+ type);
				} else {

					intent.putExtra("url",
							"/v3/product/dqDescribe?flagFresh=false&app=true&type="
									+ type);
				}
			}
			startActivity(intent);
			break;
		case R.id.detail_rl_detail2:
			intent = new Intent(DetailsActivity.this, V4WebViewActivity.class);
			intent.putExtra("title", "了解" + product_name.getText().toString());
//			if (type.equals("MONTH_WIN")) {
//				intent.putExtra("url",
//						"/v3/product/yyDescribe?flagFresh=false&type=MONTH_WIN&app=true");
//			} else if (type.equals("RECYCLE_INTEREST")) {
//				intent.putExtra("url",
//						"/v3/product/flDescribe?flagFresh=false&type=RECYCLE_INTEREST&app=true");
		 if(zhitou==0){
			 intent.putExtra("url", "/v3/product/newProDesc?type=" + type+"&productId="+id+"&app=true");
			} else if (zhitou == 1) {
				intent.putExtra("url", "/v3/product/loanDescribe?id=" + id+"&app=true");
			} else {
				String star = product_name.toString().substring(
						product_name.length() - 1, product_name.length());
				if (flag) {
					intent.putExtra("url",
							"/v3/product/newDescribe?flagFresh=true&app=true&type="
									+ type);
				} else {

					intent.putExtra("url",
							"/v3/product/dqDescribe?flagFresh=false&app=true&type="
									+ type);
				}
			}
			startActivity(intent);
			break;
		case R.id.img_back:
			finish();
			if (sha != null) {
				Editor editor = sha.edit();
				editor.clear();
				editor.commit();
			}
			break;
		case R.id.detail_rl_record:
			if (getIntent().getStringExtra("type").equals("BBT")) {
				Intent intent3 = new Intent(DetailsActivity.this,
						ProductDetailsJiluActivity.class);
				intent3.putExtra("id", id);
				intent3.putExtra("who", "BBT");
				intent3.putExtra("flagFresh", false);
				startActivity(intent3);
			}else {
				Intent intent3 = new Intent(DetailsActivity.this,
						ProductDetailsJiluActivity.class);
				intent3.putExtra("url",
						"/api/v5/product/uplanDetail/{productId}/invest");
				intent3.putExtra("id", id);
				intent3.putExtra("who", "uplan");  
				intent3.putExtra("flagFresh", false);
				startActivity(intent3);
			}
			
			
			break;
		case R.id.detail_rl_record2:
			if (getIntent().getStringExtra("type").equals("BBT")) {
				Intent intent3 = new Intent(DetailsActivity.this,
						ProductDetailsJiluActivity.class);
				intent3.putExtra("id", id);
				intent3.putExtra("who", "BBT");
				intent3.putExtra("flagFresh", false);
				startActivity(intent3);
			}else {
				Intent intent3 = new Intent(DetailsActivity.this,
						ProductDetailsJiluActivity.class);
				intent3.putExtra("url",
						"/api/v5/product/uplanDetail/{productId}/invest");
				intent3.putExtra("id", id);
				intent3.putExtra("who", "uplan");  
				intent3.putExtra("flagFresh", false);
				startActivity(intent3);
			}
			
			
			break;
		case R.id.dl_btn_pay:

			verityUser();
			break;
		case R.id.rl_youhui:
			if (tv_youhui_type.getText().toString().equals("登录查看")) {
				if (getShare().getString("mobile", "").equals("")) {
					Intent intent2 = new Intent(DetailsActivity.this,
							Log_or_RegisActivity.class);
					intent2.putExtra("who", 3);
					startActivity(intent2);
				} else {

					Intent intent3 = new Intent(DetailsActivity.this,
							LoginActivity.class);
					intent3.putExtra("who", 3);
					startActivity(intent3);
				}

				return;
			}
			if (tv_youhui_type.getText().toString().equals("无可用礼券")) {
				ToastUtil.showCenterToast(DetailsActivity.this, "无可用礼券");
				return;
			}
			rl_youhui.setEnabled(false);
			
			islogin();
			break;
		case R.id.iv_v4_nonetwork:
			initData(false);
			break;
		case R.id.img_share:
//			shareLogin();
			break;
		case R.id.rl_back:
			finish();
			if (sha != null) {
				Editor editor = sha.edit();
				editor.clear();
				editor.commit();
			}
			break;

		case R.id.enterprise_tel:
			BaseHelper.showDialog2(this, "拨号", "400-0101-016", 1);
			break;
		case R.id.img_xx:
			red_id="";
			raisingratesId="";
			rate=final_rate;
			li_fanxian.setVisibility(View.GONE);
			tv_youhui_date.setText("");
			tv_youhui_type.setText("");
			img_xx.setVisibility(View.GONE);
			tv_youhui_type.setText("去使用");
			resultcoupon = false;
			imageView1.setVisibility(View.VISIBLE);
			if (sha != null) {
				Editor editor = sha.edit();
				editor.clear();
				editor.commit();
			}
			jixi();
			break;
		case R.id.li_xx:
			red_id="";
			raisingratesId="";
			rate=final_rate;
			li_fanxian.setVisibility(View.GONE);
			tv_youhui_date.setText("");
			tv_youhui_type.setText("去使用");
			img_xx.setVisibility(View.GONE);
			resultcoupon = false;
			imageView1.setVisibility(View.VISIBLE);
			if (sha != null) {
				Editor editor = sha.edit();
				editor.clear();
				editor.commit();
			}
			jixi();
			break;
		case R.id.li_dexterity:
			if(checkBox.isChecked()){
				checkBox.setChecked(false);
			}else{
				checkBox.setChecked(true);
			}
			break;
		case R.id.li_l_yue:
			if(checkBox.isChecked()){
				checkBox.setChecked(false);
			}else{
				checkBox.setChecked(true);
			}
			break;
		

		}
	}
	private void cancle(){
		red_id="";
		raisingratesId="";
		rate=final_rate;
		li_fanxian.setVisibility(View.GONE);
		tv_youhui_date.setText("");
		tv_youhui_type.setText("");
		img_xx.setVisibility(View.GONE);
		tv_youhui_type.setText(couponMsg);
		imageView1.setVisibility(View.VISIBLE);
		if (sha != null) {
			Editor editor = sha.edit();
			editor.clear();
			editor.commit();
		}
		jixi();
	}

	private void islogin() {
		VolleryUtil volleryUtil = new VolleryUtil() {

			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				if (jsonObject.optInt("success") == 1) {
					Intent intent3 = new Intent(DetailsActivity.this,
							Investcoupon.class);
					intent3.putExtra("rate", rate);
					intent3.putExtra("month", month);
					intent3.putExtra("money", et_money.getText().toString());
					intent3.putExtra("red", availableGiftAmount);
					intent3.putExtra("isnew", isNewUesr + "");
					intent3.putExtra("isred", isred + "");
					intent3.putExtra("id", id);
					intent3.putExtra("flag", flag+"");
					intent3.putExtra("type", type);
					startActivityForResult(intent3, 0);
				} else {
					if (jsonObject.optString("comment").equals("please login")) {
						if (getShare().getString("mobile", "").equals("")) {
							Intent intent = new Intent(DetailsActivity.this,
									Log_or_RegisActivity.class);
							intent.putExtra("who", 1);
							startActivity(intent);
						} else {

							Intent intent = new Intent(DetailsActivity.this,
									LoginActivity.class);
							intent.putExtra("who", 1);
							startActivity(intent);
						}
					} else {
						ToastUtil.showCenterToast(DetailsActivity.this,
								jsonObject.optString("comment"));
					}
				}
				rl_youhui.setEnabled(true);
			}

			@Override
			public void onError() {
				// TODO Auto-generated method stub
				rl_youhui.setEnabled(true);
			}
		};
		volleryUtil.setHeaders("token", getToken());
		volleryUtil.setRequestMethod(0);
		volleryUtil.setShow(true);
		volleryUtil.execute(DetailsActivity.this, Constant.URL
				+ "apiAccount/userInfo", "");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		initData(false);
		userinfo();
	}

	private void userinfo() {
		VolleryUtil volleryUtil = new VolleryUtil() {

			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				if (jsonObject.optInt("success") == 1) {
					LogUtils.e("userinfo", jsonObject.toString());
					JSONObject json = jsonObject.optJSONObject("data");
					nameauth = json.optBoolean("nameAuth");
					islogin = true;					
					isNewUesr = json.optBoolean("isNewUser");
					availableAmount = json.optDouble("availableAmount");
					user_yue.setVisibility(View.VISIBLE);
					tv_yuan.setVisibility(View.VISIBLE);
					my_remain.setVisibility(View.VISIBLE );
					my_remain.setText(df.format(availableAmount) + "");
					pass = json.optBoolean("payPass");
					li_dexterity.setVisibility(View.VISIBLE);
					li_l_tyue.setVisibility(View.VISIBLE);
					rl_my_center.setVisibility(View.VISIBLE);
//					if (!et_money.getText().toString().equals("")
//							&& availableAmount < Integer.valueOf(et_money.getText().toString())
//							&& islogin && nameauth) {
//						btn.setText("余额不足,请充值!");
//
//					} else {
//						btn.setText("马上投资");
//					}
					

				} else {
					if (jsonObject.optString("comment").equals("please login")) {
						islogin = false;
						
						// tv_use_red.setText("使用红包"+"(未登录)");
						user_yue.setVisibility(View.GONE);
						tv_yuan.setVisibility(View.GONE);
						my_remain.setVisibility(View.GONE);
						rl_my_center.setVisibility(View.INVISIBLE);
							li_dexterity.setVisibility(View.GONE);
							li_l_tyue.setVisibility(View.GONE);
						

					} else {
						ToastUtil.showCenterToast(DetailsActivity.this,
								jsonObject.optString("comment"));
					}
				}

			}

			@Override
			public void onError() {
				// TODO Auto-generated method stub

			}
		};
		volleryUtil.setHeaders("token", getToken());
		volleryUtil.setRequestMethod(0);
		volleryUtil.execute(DetailsActivity.this, Constant.URL
				+ "apiAccount/userInfo", "");
	}

	@Override
	protected void onActivityResult(int arg0, int arg1, Intent arg2) {
		// TODO Auto-generated method stub
		super.onActivityResult(arg0, arg1, arg2);
		
		if (arg2 != null) {
			Log.e("intent", arg1+"=="+arg0);
			if(arg1==2){
				arg3=2;
				up=0;
				cancle();
			}else if(arg1==3){
				img_xx.setVisibility(View.GONE);
				li_fanxian.setVisibility(View.GONE);
			}else{
				
			
			rate = rate;
			li_fanxian.setVisibility(View.VISIBLE);
			Log.e("red", arg2.getStringExtra("red_money"));
			if (arg2.getBooleanExtra("red", false)) {
				up=1;
				img_xx.setVisibility(View.VISIBLE);
				imageView1.setVisibility(View.INVISIBLE);
				if(!tv_tishi.equals("亲,您还有加息券未使用哦!")){
					rl_comment.setVisibility(View.GONE);
				}
				red_type=arg2.getStringExtra("red_type");
				
				Log.e("result", resultred+"");
				availableGiftAmount=Double.parseDouble(arg2.getStringExtra("availableGiftAmount"));
				red_id = arg2.getStringExtra("id");
				resultred = arg2.getBooleanExtra("red", false);
				flagred = true;
				resultcoupon = false;
				proportion= Double.parseDouble(arg2.getStringExtra("rate"));
				tv_youhui_type.setText(arg2.getStringExtra("name"));
				tv_youhui_date.setText(Regular.getMilliToDate3(arg2.getStringExtra("date")));
				li_fanxian.setVisibility(View.VISIBLE);	
				Log.e("bug_rate", rate+"");
				if (isNewUesr) {
					if (!et_money.getText().toString().equals("")) {
						if(getIntent().getStringExtra("type").equals("BBT")){
							if(red_type.equals("PERCENTAGE")){
								double redpage = Double.valueOf(et_money
										.getText().toString()) * (0.005);
								if (redpage > availableGiftAmount) {
									redpage = availableGiftAmount;
								}
								tv_v4_pay_redpackage.setText(df.format(redpage)
										+ "元");
							}else{
								
								double redpage = Double.valueOf(et_money
										.getText().toString()) * (proportion/100)/365*qixian;
								if (redpage > availableGiftAmount) {
									redpage = availableGiftAmount;
								}
								tv_v4_pay_redpackage.setText(df.format(redpage)
										+ "元");
							}
						}else{
							if(red_type.equals("PERCENTAGE")){
								double redpage = Double.valueOf(et_money
										.getText().toString()) * (0.005);
								if (redpage > availableGiftAmount) {
									redpage = availableGiftAmount;
								}
								tv_v4_pay_redpackage.setText(df.format(redpage)
										+ "元");
							}else{
								
								double redpage = Double.valueOf(et_money
										.getText().toString()) * (proportion/100)/365*month;
								if (redpage > availableGiftAmount) {
									redpage = availableGiftAmount;
								}
								tv_v4_pay_redpackage.setText(df.format(redpage)
										+ "元");
							}
						}
						if (getIntent().getStringExtra("type")
								.equals("BBT")) {
							double a = VoteCalculator
									.getVoteCalculator_newuser(et_money
											.getText().toString(), rate,
											month);
 
							DecimalFormat df = new DecimalFormat(
									"######0.00");
							tv_v4_pay_shouyi.setText(df.format(a) + "元");
						} else {
							DecimalFormat df = new DecimalFormat(
									"######0.00");
							double a = VoteCalculator
									.getVoteCalculator_month(et_money
											.getText().toString(), rate,
											month);
							tv_v4_pay_shouyi.setText(df.format(a) + "元");
						}
					} else {
						tv_v4_pay_redpackage.setText("0.00" + "元");
						tv_v4_pay_shouyi.setText("0.00" + "元");
					}

				} else {
					if (!et_money.getText().toString().equals("")) {
						double b=0;
						if(getIntent().getStringExtra("type").equals("BBT")){
							if(red_type.equals("PERCENTAGE")){
								b = Double.valueOf(et_money
										.getText().toString()) * (0.005);
							}else{
								b = Double.valueOf(et_money
										.getText().toString()) * (proportion/100)/365*qixian;
							}
							if (b > availableGiftAmount) {
								b = availableGiftAmount;
							}
							
						}else{
							if(red_type.equals("PERCENTAGE")){
								 b = Double.valueOf(et_money
											.getText().toString()) * (0.005);
							}else{
								 b = Double.valueOf(et_money
											.getText().toString()) * (proportion/100)/365*month;
							}
							if (b > availableGiftAmount) {
								b = availableGiftAmount;
							}
							
						}
						if (b < availableGiftAmount) {
							DecimalFormat df = new DecimalFormat(
									"######0.00");
							tv_v4_pay_redpackage.setText(df.format(b) + "元");
							if (getIntent().getStringExtra("type").equals(
									"BBT")) {
								double a = VoteCalculator
										.getVoteCalculator_newuser(et_money
												.getText().toString(),
												rate, month);

								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							} else {

								double a = VoteCalculator
										.getVoteCalculator_month(et_money
												.getText().toString(),
												rate, month);
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							}
						} else {
							if (getIntent().getStringExtra("type").equals(
									"BBT")) {
								double a = VoteCalculator
										.getVoteCalculator_newuser(et_money
												.getText().toString(),
												rate, month);

								DecimalFormat df = new DecimalFormat(
										"######0.00");
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							} else {
								DecimalFormat df = new DecimalFormat(
										"######0.00");
								double a = VoteCalculator
										.getVoteCalculator_month(et_money
												.getText().toString(),
												rate, month);
								tv_v4_pay_shouyi.setText(df.format(a) + "元");
							}
							tv_v4_pay_redpackage
									.setText(availableGiftAmount + "元");
						}
					} else {
						tv_v4_pay_redpackage.setText("0.00" + "元");
						tv_v4_pay_shouyi.setText("0.00" + "元");
					}
				}
			} else {
				up=1;
				if(!tv_tishi.equals("亲,您还有红包未使用哦!")){
					rl_comment.setVisibility(View.GONE);
				}
				img_xx.setVisibility(View.VISIBLE);
				imageView1.setVisibility(View.INVISIBLE);
				resultred =false;
				flagred = false;
				resultcoupon = true;
				raisingratesId = arg2.getStringExtra("id");
				tv_v4_pay_redpackage.setText(arg2.getStringExtra("red_money"));
				LogUtils.e("红包返现金额", arg2.getStringExtra("red_money"));
				li_fanxian.setVisibility(View.GONE);
				rate=final_rate;
				rate = rate + Double.parseDouble(arg2.getStringExtra("rate"));
                add_rate=Double.parseDouble(arg2.getStringExtra("rate"));
				jixi();
				tv_youhui_type.setText(arg2.getStringExtra("name"));
				tv_youhui_date.setText(Regular.getMilliToDate3(arg2.getStringExtra("date")));
			}

		}
		}
	}
public void jixi(){
	if (isNewUesr) {
		if (!et_money.getText().toString().equals("")) {
			double redpage = Double.valueOf(et_money.getText()
					.toString()) * (proportion/100);
			if (redpage > availableGiftAmount) {
				redpage = availableGiftAmount;
			}

			if (getIntent().getStringExtra("type").equals("BBT")) {
				double a = VoteCalculator
						.getVoteCalculator_newuser(et_money
								.getText().toString(), rate, month);

				DecimalFormat df = new DecimalFormat("######0.00");
				tv_v4_pay_shouyi.setText(df.format(a) + "元");
			} else {
				DecimalFormat df = new DecimalFormat("######0.00");
				double a = VoteCalculator.getVoteCalculator_month(
						et_money.getText().toString(), rate, month);
				tv_v4_pay_shouyi.setText(df.format(a) + "元");
			}
		}
	} else {
		if (!et_money.getText().toString().equals("")) {
			double b = Double
					.valueOf(et_money.getText().toString()) * (proportion/100);
			if (b < availableGiftAmount) {
				if (getIntent().getStringExtra("type")
						.equals("BBT")) {
					double a = VoteCalculator
							.getVoteCalculator_newuser(et_money
									.getText().toString(), rate,
									month);

					DecimalFormat df = new DecimalFormat(
							"######0.00");
					tv_v4_pay_shouyi.setText(df.format(a) + "元");
				} else {
					DecimalFormat df = new DecimalFormat(
							"######0.00");
					double a = VoteCalculator
							.getVoteCalculator_month(et_money
									.getText().toString(), rate,
									month);
					tv_v4_pay_shouyi.setText(df.format(a) + "元");
				}
			} else {
				if (getIntent().getStringExtra("type")
						.equals("BBT")) {
					double a = VoteCalculator
							.getVoteCalculator_newuser(et_money
									.getText().toString(), rate,
									month);

					DecimalFormat df = new DecimalFormat(
							"######0.00");
					tv_v4_pay_shouyi.setText(df.format(a) + "元");
				} else {
					DecimalFormat df = new DecimalFormat(
							"######0.00");
					double a = VoteCalculator
							.getVoteCalculator_month(et_money
									.getText().toString(), rate,
									month);
					tv_v4_pay_shouyi.setText(df.format(a) + "元");
				}

			}
		}
	}
}
	private void verityUser() {
		VolleryUtil vollery = new VolleryUtil() {

			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				if (jsonObject.optInt("success") == 1) {
					JSONObject json = jsonObject.optJSONObject("data");
					availableGiftAmount = json.optDouble("availableGiftAmount");
					Intent intent = null;
					if (!json.optBoolean("nameAuth")
							&& !json.optBoolean("isBindCard")) {
						intent = new Intent(DetailsActivity.this,
								RealName.class);
						startActivity(intent);
						return;
					}
					if (json.optString("bankMobileStatus") != null
							&& !json.optString("bankMobileStatus").equals("")
							&& json.optString("bankMobileStatus").equals(
									"WAIT_CHECK")) {
						intent = new Intent(DetailsActivity.this,
								BankCardActivity.class);
						intent.putExtra("bankcard", json.optString("cardNo"));
						intent.putExtra("isbank", 1);
						intent.putExtra("logourl", json.optString("logoUrl"));
						intent.putExtra("banknameEn",
								json.optString("bankNameEn"));
						intent.putExtra("banknameCn",
								json.optString("bankNameCn"));
						intent.putExtra("status",
								json.optString("bankMobileStatus"));
						startActivity(intent);
						return;
					}
					if (!json.optBoolean("isBindCard")) {	
						intent = new Intent(DetailsActivity.this,
								BankCardActivity.class);
						startActivity(intent);
						return;
					}

					if (btn.getText().toString().equals("余额不足,请充值!")) {

						Intent intent5 = new Intent(DetailsActivity.this,
								V4AddMoneySActiviy.class);
						startActivity(intent5);
						return;
					}
					if (et_money.getText().toString().equals("")) {
						ToastUtil.showCenterToast(DetailsActivity.this,
								"请输入投资金额");
						return;
					}
					if(minAmount>remainAmount){
//						if((Integer.valueOf(et_money.getText().toString())!=remainAmount)){
//							ToastUtil.showCenterToast(DetailsActivity.this,
//									"投资金额的增量要为" + increaseNum + "的倍数");
//							return;
//						}
		//ss						
					}else{
						if (Integer.valueOf(et_money.getText().toString()) < minAmount) {
							ToastUtil.showCenterToast(DetailsActivity.this,
									"投资额不能小于最低起投金额");
							return;
						}
					}
					

					if (maxAmount != 0) {
						if (Integer.valueOf(et_money.getText().toString()) > maxAmount) {
							ToastUtil.showCenterToast(DetailsActivity.this,
									"最大投资金额为" + maxAmount + "元");
							return;
						}
					}

					// if(remainAmount<increaseNum){
					//
					// }
					if(minAmount>remainAmount){
//						if((Integer.valueOf(et_money.getText().toString())!=remainAmount)){
//							ToastUtil.showCenterToast(DetailsActivity.this,
//									"投资金额的增量要为" + increaseNum + "的倍数");
//							return;
//						}
								
					}else{
						if ((Integer.valueOf(et_money.getText().toString()) - minAmount)
								% increaseNum != 0) {
							ToastUtil.showCenterToast(DetailsActivity.this,
									"投资金额的增量要为" + increaseNum + "的倍数");
							return;
						}
					}
					
					if (!json.optBoolean("payPass")) {
						intent = new Intent(DetailsActivity.this,
								Set_tr_pw.class);
						startActivity(intent);
						return;
					}
					if((tv_youhui_type.getText().toString().equals("去使用")&&tishi_coupon)){
						tishi_coupon=false;
						rl_comment.setVisibility(View.VISIBLE);
						tv_tishi.setText("亲，您还有未使用的礼券哦!");
						Toast.makeText(DetailsActivity.this, "亲，您还有未使用的礼券哦!", 2000).show();
						return;
					}
//					Log.e("红包是否使用，是否是有红包，是否使用加息券", flagred+""+availableGiftAmount+""+resultcoupon+"");
//					if(!flagred&&availableGiftAmount>0&&isred&&!resultcoupon&&tishi_coupon){
//						tishi_coupon=false;
//						rl_comment.setVisibility(View.VISIBLE);
//						tv_tishi.setText("亲,您还有红包未使用哦!");
//						Toast.makeText(DetailsActivity.this, "亲,您还有红包未使用哦!", 2000).show();
//						return;
//					}
					Log.e("加息券，是否使用加息券", raisingratesFlag+""+resultcoupon+"");
//					if(raisingratesFlag&&!resultcoupon&&!flagred&&tishi_coupon){
//						tishi_coupon=false;
//						rl_comment.setVisibility(View.VISIBLE);
//						tv_tishi.setText("亲,您还有加息券未使用哦!");
//						Toast.makeText(DetailsActivity.this, "亲,您还有加息券未使用哦!", 2000).show();
//						return;
//					}
					/*
					 * if (!json.optBoolean("isBindCard")) { intent = new
					 * Intent(
					 * ProductDetailsActivity.this,V4BankCardActivity.class);
					 * startActivity(intent); return; }
					 */
					if(resultcoupon){
						flagcoupon();
					}else{
						intent = new Intent(DetailsActivity.this, PayActivity.class);
						intent.putExtra("flagRedpack", flagred);
						intent.putExtra("rate", rate);
						intent.putExtra("qixian", qixian);
						intent.putExtra("minAmount", minAmount);
						intent.putExtra("isZhi", zhitou);
						intent.putExtra("red_id", red_id);
						intent.putExtra("productId", loanid);
						intent.putExtra("title_tpye", type);
						intent.putExtra("increaseNum", stepAmount);
						intent.putExtra("remainAmount", remainAmount);
						intent.putExtra("money", et_money.getText().toString());
						intent.putExtra("flagcoupon", resultcoupon);
						intent.putExtra("useCurrentAmountToInvest", ishuo);
						startActivityForResult(intent,0);
						overridePendingTransition(R.anim.slide_in_from_bottom,
								R.anim.slide_out_to_bottom);
					}
//					intent = new Intent(DetailsActivity.this, PayActivity.class);
//					intent.putExtra("flagRedpack", flagred);
//					intent.putExtra("rate", rate);
//					intent.putExtra("qixian", qixian);
//					intent.putExtra("minAmount", minAmount);
//					intent.putExtra("isZhi", zhitou);
//					intent.putExtra("productId", id);
//					intent.putExtra("title_tpye", type);
//					intent.putExtra("increaseNum", stepAmount);
//					intent.putExtra("remainAmount", remainAmount);
//					intent.putExtra("money", et_money.getText().toString());
//					intent.putExtra("flagcoupon", resultcoupon);
					Log.e("加息券", flagcoupon + "");
//					if (resultcoupon) {
//						intent.putExtra("raisingratesId", raisingratesId);
//					}
					System.out.println("productdetails=rate===" + rate);
//					if (!json.optBoolean("payPass")) {
//						intent.putExtra("setPass", 1);
//					}

					

				} else {
					if (jsonObject.optString("comment").equals("please login")) {
						if (getShare().getString("mobile", "").equals("")) {
							Intent intent = new Intent(DetailsActivity.this,
									Log_or_RegisActivity.class);
							intent.putExtra("who", 5);
							startActivity(intent);

						} else {

							Intent intent = new Intent(DetailsActivity.this,
									LoginActivity.class);
							intent.putExtra("who", 3);
							startActivity(intent);

						}
					} else {
						ToastUtil.showCenterToast(DetailsActivity.this,
								jsonObject.optString("comment"));
					}
				}
			}

			@Override
			public void onError() {
				// TODO Auto-generated method stub

			}
		};
		vollery.setHeaders("token", getToken());
		vollery.setHeaders("client", "android");
		vollery.setShow(true);
		vollery.setRequestMethod(0);
		vollery.execute(DetailsActivity.this, Constant.URL
				+ "/api/v5/user/userInfo", "");
	}

	@Override
	public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
		// TODO Auto-generated method stub

	}

//	private void shareLogin() {
//		VolleryUtil vollery = new VolleryUtil() {
//
//			@Override
//			public void onUpDate(JSONObject jsonObject) {
//				// TODO Auto-generated method stub
//				if (jsonObject.optInt("success") == 1) {
//					Log.e("share_biao", jsonObject.toString());
//					JSONObject json1 = jsonObject.optJSONObject("data");
//					Intent intent = new Intent(DetailsActivity.this,
//							WXEntryActivity.class);
//					intent.putExtra("sharelink", json1.optString("linkUrl"));
//					intent.putExtra("description",
//							json1.optString("description"));
//					intent.putExtra("title", json1.optString("title"));
//					intent.putExtra("imgurl", json1.optString("imageUrl"));
//					startActivity(intent);
////					LogUtils.e("url", Constant.URL + "/api/shareProductContent/"
////							+ type + "/" + id);
//					
//				}
//			}
//
//			@Override
//			public void onError() {
//				// TODO Auto-generated method stub
//
//			}
//		};
//
//		vollery.setHeaders("token", getToken());
//		vollery.setHeaders("client", "android");
//		vollery.setShow(true);
//		vollery.setRequestMethod(0);
//		vollery.execute(DetailsActivity.this, Constant.URL
//				+ "/api/shareProductContent/" + type + "/" + id, "");
//	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (sha != null) {
			Editor editor = sha.edit();
			editor.clear();
			editor.commit();
		}
		return super.onKeyDown(keyCode, event);
	}
	public void flagcoupon(){
		AjaxParams params=new AjaxParams();
		params.put("productId", id);
		params.put("amount", et_money.getText().toString());
		params.put("raisingratesId", raisingratesId);
		params.put("type", producttype);
		params.put("useCurrentAmountToInvest", ishuo+"");
		VolleryUtil volleryUtil=new VolleryUtil() {
			
			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				if(jsonObject.optInt("success")==1){
					LogUtils.e("加息券校验", jsonObject.toString());
					Intent intent = new Intent(DetailsActivity.this, PayActivity.class);
					intent.putExtra("flagRedpack", flagred);
					intent.putExtra("rate", rate);
					intent.putExtra("qixian", qixian);
					intent.putExtra("minAmount", minAmount);
					intent.putExtra("isZhi", zhitou);
					intent.putExtra("productId", id);
					intent.putExtra("title_tpye", type);
					intent.putExtra("increaseNum", stepAmount);
					intent.putExtra("remainAmount", remainAmount);
					intent.putExtra("money", et_money.getText().toString());
					intent.putExtra("flagcoupon", resultcoupon);
					intent.putExtra("raisingratesId", raisingratesId);
					intent.putExtra("useCurrentAmountToInvest", ishuo);
					startActivityForResult(intent, 1);
					overridePendingTransition(R.anim.slide_in_from_bottom,
							R.anim.slide_out_to_bottom);
				}else{
					Toast.makeText(DetailsActivity.this, jsonObject.optString("comment"), 2000).show();
				}
			}
			
			@Override
			public void onError() {
				// TODO Auto-generated method stub
				
			}
		};
		volleryUtil.setHeaders("token", getToken());
//		volleryUtil.setHeaders("deviceId", getdeviceId());
		volleryUtil.setRequestMethod(1);
		volleryUtil.setShow(true);
		volleryUtil.execute(DetailsActivity.this, Constant.URL+"/api/v6/invest/invests/valid?", params.toString());
	}
}
